The present invention relates to electronic data processing, and more specifically concerns a software tool for generating a set of translation-code modules for translating application-program interfaces (APIs) from one platform to another, for use with an emulator which allows application programs written for one platform to be executed on a different platform.
Present-day application programs almost never interface directly to the hardware of the computer system in which they execute. Instead, application program interfaces (APIs) call code modules which control the hardware, or which call programmed interfaces at yet lower levels. Most API code modules reside in an operating system (OS), although others may exist in a basic input/output system (BIOS), or in other places. Code modules for API functions typically reside in freestanding dynamic link library (DLL) files each containing routines for carrying out dozens or even hundreds of API functions.
Executing an application program written for one computer processor, operating system, or other platform on another platform requires a program, variously known as an emulator, simulator, interpreter, or translator, to convert instructions, data formats, application-program interfaces (APIs), and other characteristics of the application from those of its original platform to those of the native platform in which the emulator runs. Sometimes the original platform has been replaced, but the old application must still be run on the new platform. Sometimes programs are written to an abstract platform, so that the same application can be executed on numerous different platforms merely by writing an emulator for each native platform that is to host the abstract platform.
An emulator subsystem generally has two major components. The emulator itself converts the original processor instructions from the application into instructions or groups of instructions appropriate to the processor of the new platform, and executes them. An API translation layer xe2x80x9cthunksxe2x80x9d API calls from the original platform being emulated into calls to APIs written for the native platform; that is, it intercepts API calls made by an application written for the emulated platform, converts their arguments from the calling convention of the original platform to that of the native platform, then calls an appropriate native-platform module for executing the API function. A translation module or xe2x80x9cAPI thunkxe2x80x9d is a piece of program code in the translation layer which executes between a particular original API and the operating system running on the native platform.
Conventional practice involves hand-writing thunk code for each new and modified API. However, an API set may change daily during the development of an operating system. Also, the number of APIs can be very large. The Microsoft(copyright) Windows(copyright) NT(copyright)-operating system, for example, contains more than 3,500 APIs in 42 different DLL modules. Therefore, manual production of individual API translation code becomes increasingly impractical. Increasingly shorter product cycles compounds this problem.
Some interface modules or thunks have been generated from hand-written descriptors for each separate API. However these must be maintained separately from the APIs themselves, and thus involve costly additional effort. They also suffer from synchronization problems: if one or more modules inadvertently escape an update between one development iteration and the next, their down-level code may mistranslate an API, or may crash the system. Such problems can be difficult to find, thus forcing the entire development effort to wait.
Alternatively, a software tool has been employed to create a set of skeleton API thunks as C-language source files which were then hand-modified. This approach is impractical, in that rerunning the tool destroys all the hand edits.
A utility program according to the present invention creates and automatically updates code modules for translating APIs written for one platform so that they will execute properly on a different platform. The utility, executed for every new development iteration of an operating system or other software environment, uses a set of templates for constructing source code for the translation modules, based upon the functions performed by the APIs. Special translation requirements are handled by exception templates containing personalized translation code. Another kind of template performs type conversions from the original APIs"" parameters or arguments into those of the different platform.
Automatic code generation in this manner enables much faster development iterations by providing an automated method of synchronizing the translation modules with changes made to the new operating system or environment. The code generator ensures that all translation modules are at the current updated level, which prevents system crashes caused by incompatible modules. It also greatly reduces errors within individual code modules resulting from prior hand generation methods, and eliminates errors across modules caused from different people working independently on different modules.
Other features and advantages, as well as modifications and additions within the scope of the invention, will appear to those skilled in the art from the following description.